#ifndef BHXJCOMPASS2D_H
#define BHXJCOMPASS2D_H

#include <QOpenGLWidget>
#include "BHXJGLHelper/bhxjglshader.h"
#include "BHXJControls_global.h"
#include "bhxjglrectangle.h"
#include "BHXJGLHelper/bhxjglcamera.h"
#include "BHXJGLHelper/bhxjglttf.h"
#include<QDebug>
#include "bhxjglpointer1.h"
#include "BHXJGLHelper/bhxjglmodel.h"
class BHXJCONTROLS_EXPORT BHXJCompass2D :  public QOpenGLWidget,protected BHXJGLFUN
{
    Q_OBJECT
public:
    explicit BHXJCompass2D(QWidget *parent = nullptr);

    Q_PROPERTY(QColor BackColor READ BackColor WRITE setBackColor)
    QColor BackColor(){return _BackColor;}
    void setBackColor(QColor value){_BackColor=value;this->Refrush();}

    Q_PROPERTY(QColor PointerColor READ PointerColor WRITE setPointerColor)
    QColor PointerColor(){return _PointerColor;}
    void setPointerColor(QColor value){_PointerColor=value;this->Refrush();}

    Q_PROPERTY(QColor NormalColor READ NormalColor WRITE setNormalColor)
    QColor NormalColor(){return _NormalColor;}
    void setNormalColor(QColor value){_NormalColor=value;this->Refrush();}

    Q_PROPERTY(QColor Color_N READ Color_N WRITE setColor_N)
    QColor Color_N(){return _Color_N;}
    void setColor_N(QColor value){_Color_N=value;this->Refrush();}

    Q_PROPERTY(QColor Color_S READ Color_S WRITE setColor_S)
    QColor Color_S(){return _Color_S;}
    void setColor_S(QColor value){_Color_S=value;this->Refrush();}

    Q_PROPERTY(QColor Color_W READ Color_W WRITE setColor_W)
    QColor Color_W(){return _Color_W;}
    void setColor_W(QColor value){_Color_W=value;this->Refrush();}

    Q_PROPERTY(QColor Color_E READ Color_E WRITE setColor_E)
    QColor Color_E(){return _Color_E;}
    void setColor_E(QColor value){_Color_E=value;this->Refrush();}

    Q_PROPERTY(float Direction READ Direction WRITE setDirection)
    float Direction(){return _Direction;}
    void setDirection(float value)
    {
        value=std::fmod(value,360.f);
        _Direction=value;
        this->Refrush();
    }

    Q_PROPERTY(bool PointerMove READ PointerMove WRITE setPointerMove)
    bool PointerMove(){return _PointerMove;}
    void setPointerMove(bool value){_PointerMove=value;this->Refrush();}

    Q_PROPERTY(bool CN READ CN WRITE setCN)
    bool CN(){return _CN;}
    void setCN(bool value){_CN=value;this->Refrush();}


signals:
    void Refrush();
public slots:

protected:
    QColor _BackColor{80,80,80};
    QColor _PointerColor=Qt::red;
    QColor _NormalColor{255,255,255};  //=Qt::black;
    QColor _Color_N=Qt::red;
    QColor _Color_S{20,100,255};//=Qt::blue;
    QColor _Color_W{255,255,255};//=Qt::black;
    QColor _Color_E{255,255,255};//=Qt::black;
    float _Direction=0;
    bool _PointerMove=false;
    bool _CN=false;

    void initializeGL() override;
    void paintGL() override;
    void resizeGL( int width, int height ) override;
    void paintStrCn(const QString &str, float angle,const glm::vec2 &size,float distance,const QColor &color,glm::mat4 matview);
    void paintStrEn(const QString &str, float angle,const glm::vec2 &size,float distance,const QColor &color,glm::mat4 matview);

    void setprojection(float width,float height);

    BHXJGLShader myshader;
    BHXJGLShader ttfshader;
    BHXJGLShader pointer1shader;
    BHXJGLCamera camera;
    BHXJGLTTF ttfcn;
    BHXJGLTTF ttfen;

    BHXJGLRectangle rectangle;
    BHXJGLPointer1 pointer1;
    BHXJGLTexture2D texture;

    float fragwidth;
    glm::mat4 projection;
    glm::mat4 model = glm::mat4(1.0f);
    glm::mat4 view = glm::mat4(1.0f);



};

#endif // BHXJCOMPASS2D_H
